HTTP PDF Invoice Request

This straightforward workflow simply receives a GET request from a browser, loads an existing PDF invoice from a folder on the hard drive, and returns it to the browser. To do this, a client (or a web service) would request the following page:

http://ppworkflowserver:8080/getinvoice?in=INV999999

Breakdown of this URL:

  • http:// : transfer protocol. This could be HTTPS if the SSL certificates are activated in the preferences.
  • ppworkflowserver : name of the machine. This could also be an IP (192.168.1.123) or a full domain name (www.myserver.com), depending on the connectivity between the client and PlanetPress Workflow Server.
  • :8080 : The default PlanetPress Workflow HTTP Port, set in the preferences.
  • /getinvoice : The HTTP Action Name, as set in the HTTP Server Input task.
  • ?in=INV999999 : A GET Variable, specifying that the variable named invoicenum (invoice number) would have a value of INV999999 , or any other "valid" invoice number.

Process illustration

Task breakdown

  • The HTTP Server Input task receives a request through the /getinvoice HTTP Action. Because this task either returns an HTML page with an error message or a PDF, the MIME type is Auto-Detect.
  • It checks whether the invoice request exists by checking if the size of the file is less than 1kb using File Size Condition. The condition returns "true" if the file is not found:
    c:\PlanetPress\archives\pdf\invoices\xmlget('/request[1]/values[1]/invoicenum[1]',Value,KeepCase,NoTrim).pdf
    Here, the xmlget() function grabs the invoicenum variable from the GET request, which would be INV999999.pdf in the specified folder.
  • If the file is not found, then a simple, basic HTML page is created indicating the invoice was not found. For this, a Create File task will suffice, followed by the Delete output task. As mentioned in HTTP Server workflow, deleting the data file only means you are not doing anything with it locally - it is still returned to the client.
    Instead of creating a web page from scratch, you could create a web page from a Connect Web template; use the Create Web Content task.
  • If, however, the file is found, then it is loaded with the Load External File task, and then deleted (for the same reasons).